﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Jwell.Template.App.MyWindow
{
    public partial class SolutionOptionsDialog : Form
    {
        /// <summary>
        /// 项目配置
        /// </summary>
        public SolutionOption Option { get; set; }

        public SolutionOptionsDialog(SolutionOption option)
        {
            this.Option = option ?? throw new Exception("选项参数不能够为空");
            InitializeComponent();

            //定义自己的初始化操作
            this.comboBox1.DataSource = SolutionOption.FrameworkVersions;
        }

        /// <summary>
        /// 确定按钮的事件参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            this.SaveOption();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        /// <summary>
        /// 取消按钮的事件参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }


        private void textBox1_Enter(object sender, EventArgs e)
        {
            this.solutionPathDialog.ShowDialog();
            this.tbSolutionPath.Text = this.solutionPathDialog.SelectedPath;
        }



        /// <summary>
        /// 保存相关的配置
        /// </summary>
        private void SaveOption()
        {
            this.Option.RootNameSpace = this.tbRootNamespace.Text;
            this.Option.TargetFrameworkVersion = this.comboBox1.SelectedText;
            this.Option.SolutionName = this.tbSolutionName.Text;
            this.Option.SolutionPath = this.tbSolutionPath.Text;
        }
    }
}
